home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-01-12 | 3.9 KB | 112 lines | [TEXT/ToyS] |
- property history : ["http://www.apple.com", "http://www.hylight.demon.co.uk"]
- property dRect : null
- property dlog : {bounds:null, name:"Connect To…", closeable:true, style:standard window, contents:[¬
- {class:push button, bounds:[260, 190, 330, 210], font:1, name:"Connect", enabled:5}, ¬
- {class:push button, bounds:[10, 190, 50, 210], name:"Add", enabled:5}, ¬
- {class:push button, bounds:[60, 190, 100, 210], name:"Delete", enabled:4}, ¬
- {class:list box, bounds:[10, 10, 330, 129], font:2, value:1, action:44, flags:2 - 128}, ¬
- {class:text field, bounds:[13, 161, 327, 177]}, ¬
- {class:push button, bounds:[120, 190, 160, 210], name:"Load…"}, ¬
- {class:push button, bounds:[170, 190, 210, 210], name:"Save…"}, ¬
- {class:static text, bounds:[10, 139, 330, 155], contents:"Enter an Internet address (URL):"} ¬
- ]}
- property QuitOnConnect : false
- --localize these strings:
- property OKButton : "OK"
- --most error messages should be handled by the OSAX itself:
- property generalErrorMessage : "Your Internet software is not configured correctly. " & ¬
- "Please use the Mac OS installer to re-install your Internet software."
-
- if («event GURLiast») is true then
- dd install with fonts [null, {name:"Geneva", size:10}] with greyscale --System, Control, Label, Data
- if dRect = null then
- set bounds of dlog to dd calc dialog bounds [340, 220]
- else
- set bounds of dlog to dRect
- end if
- set d to dd make dialog dlog
- dd set contents of item 4 of d to history
- dd set value of item 4 of d to history's length
- if history's length > 0 then dd set value of item 5 of d to history's item -1
- repeat
- set i to dd interact with user
- if i = 1 then
- if Connect(dd get value of item 5 of d) and QuitOnConnect then exit repeat
- else if i = 2 then -- Add
- set history to history & (dd get value of item 5 of d)
- dd set contents of item 4 of d to history
- dd set value of item 4 of d to history's length
- else if i < 0 then -- Close Window
- exit repeat
- else if i = 6 then -- Load
- try
- set f to open for access (choose file with prompt "Read URLs from:" of type "TEXT")
- try
- if ((get eof f) > 30000) then error -128
- set history to []
- repeat
- set history to history & (read f before return)
- end repeat
- on error
- end try
- close access f
- dd set contents of item 4 of d to history
- dd set value of item 4 of d to history's length
- on error
- end try
- else if i = 7 then -- Save
- try
- set f to open for access (new file with prompt "Save URLs in:" default name "Connect To URLs") with write permission
- try
- set eof f to 0
- repeat with u in history
- write u & return to f
- end repeat
- on error
- end try
- close access f
- on error
- end try
- else
- set n to dd get value of item 4 of d
- if n ≠ 0 then
- if i = 3 then -- Delete
- if n = history's length then
- if n = 1 then
- set history to []
- else
- set history to items 1 thru (n - 1) of history
- end if
- else if n = 1 then
- set history to items 2 thru -1 of history
- else
- set history to items 1 thru (n - 1) of history & items (n + 1) thru -1 of history
- end if
- dd set contents of item 4 of d to history
- else if i = 4 then -- List
- set url to history's item n
- dd set value of item 5 of d to url
- else if i = 44 then -- Doubleclick
- set url to history's item n
- dd set value of item 5 of d to url
- if Connect(url) and QuitOnConnect then exit repeat
- end if
- end if
- end if
- end repeat
- set dRect to dd get bounds of d
- dd uninstall
- end if
-
- on Connect(url)
- try
- open url (url) with report errors
- on error errorMessage number errorNumber
- if errorNumber = -1708 then --no Internet Scripting Addition osax
- display dialog generalErrorMessage & return & return & " (Error number: " & errorNumber & ¬
- ")" buttons [OKButton] default button OKButton
- end if
- return false
- end try
- return true
- end Connect